﻿<%@ Page Title="" Language="C#" MasterPageFile="~/TsSite.Master" AutoEventWireup="true" CodeBehind="Preparation.aspx.cs" Inherits="TireService.Web.View.ServiceView.Preparation" %>

<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxSplitter" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPanel" tagprefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxGridView.v11.1.Export, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxGridView.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dxwgv" %>
<%@ Register assembly="DevExpress.Web.ASPxEditors.v11.1, Version=11.1.12.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dxe" %>


<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    
    <table cellpadding="0" cellspacing="2" border="0">
        <tr>
            <td>
                <img id="imgTaskCompletion" alt="" src="~/Images/Medium/cubes_yellow.png" runat="server" style="width: 32px; height: 32px" />
            </td>
            <td valign="middle">
                <h3><asp:Label ID="lblPackingHeader" runat="server" Text="Pakkeliste"></asp:Label></h3>
            </td>
        </tr>
    </table>
    <hr />
            
    <!-- Javascript of action dropdown list -->
    <script language="javascript" type="text/javascript">

        // Function that handles actions selected in dropdown list
        function ActionClicked() {

            // Get selected action from dropdownlist
            var id = ddlAction.GetValue();

            if (id != null && id != 0) {

                // Print labels
                if (id == 1) {
                    //Response.Redirect("~/Reports/View/ServiceCarScheduleReportView.aspx?ContainerId=" + ddlContainer.Value.ToString() + "&ScheduleDate=" + calScheduleDate.Value.ToString());

                    // Get selected items in gridview and trigger event ShowTireSetLabels 
                    gvServiceCarSchedulePacking.GetSelectedFieldValues('ContainerCargoRoomId', ShowTireSetLabels);
                }

                // Print serviceschedule
                if (id == 2) {
                    ShowPlanningSchedule();
                }
            }
            else {
                alert('Ingen handling valgt');
            }
        }

        // Show popup with labels for selected tiresets
        function ShowTireSetLabels(selectedValues) {
            if (selectedValues.length == 0) return;

            window.open('../../Reports/View/TireSetLabels.aspx?ContainerCargoRoomId=' + selectedValues);
        }

        // Show popup with planning schedule
        function ShowPlanningSchedule() {
            var scheduleDate = new Date(calScheduleDate.GetValue());
            var stringDate = scheduleDate.getDate() + "-" + (1 + scheduleDate.getMonth()) + "-" + scheduleDate.getFullYear();

            window.open('../../Reports/View/ServiceCarScheduleReportView.aspx?ContainerId=' + ddlContainer.GetValue() + "&ScheduleDate=" + stringDate, 'Kørselsskema');
        }

    </script>        

    <table border="0" cellspacing="0" cellpadding="5" width="100%">
        <tr>
            <td style="width:150px">
                <dxe:ASPxComboBox ID="ddlAction" ClientInstanceName="ddlAction" runat="server" Width="150px">
                    <Items>
                        <dxe:ListEditItem Selected="true" Value="0" Text="-- Handling --" />
                        <dxe:ListEditItem Value="1" Text="Udskriv labels" />
                        <dxe:ListEditItem Value="2" Text="Udskriv kørselsskema" />
                    </Items>
                </dxe:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dxe:ASPxButton ID="btnSubmitAction" runat="server" Text="Udfør" AutoPostBack="False" UseSubmitBehavior="False" Width="75px">
                    <ClientSideEvents Click="function(s, e) { ActionClicked(); }" />
                </dxe:ASPxButton>
            </td>
            <td style="width:150px">
                <dxe:ASPxComboBox ID="ddlExport" ClientInstanceName="ddlExport" runat="server" Width="150px">
                    <Items>
                        <dxe:ListEditItem Selected="True" Value="0" Text="Export pdf" />
                        <dxe:ListEditItem Value="1" Text="Export xls" />
                        <dxe:ListEditItem Value="2" Text="Export csv" />
                        <dxe:ListEditItem Value="3" Text="Export rtf" />
                    </Items>
                </dxe:ASPxComboBox>
            </td>
            <td style="width:75px">
                <dxe:ASPxButton ID="btnExport" runat="server" Text="Exporter" OnClick="btnExport_Click" Width="75px" >
                </dxe:ASPxButton>
            </td>
            <td align="right">
                <asp:Label ID="lblView" runat="server" Text="Visning"></asp:Label>
                <asp:DropDownList ID="ddlView" runat="server" AutoPostBack="True" 
                    onselectedindexchanged="ddlView_SelectedIndexChanged">
                    <asp:ListItem Value="0">Grupper efter Bil</asp:ListItem>
                    <asp:ListItem Value="1">Grupper efter Lagerplads</asp:ListItem>
                </asp:DropDownList>
                &nbsp;
                <asp:Label ID="lblPageSize" runat="server" Text="Antal linjer pr side"></asp:Label>
                <asp:DropDownList ID="ddlPageSize" runat="server" AutoPostBack="true">
                    <asp:ListItem Value="10">10</asp:ListItem>
                    <asp:ListItem Value="25">25</asp:ListItem>
                    <asp:ListItem Value="50">50</asp:ListItem>
                    <asp:ListItem Value="100">100</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
    </table>
    <hr />          
                
    
    <dx:ASPxSplitter ID="splitterServiceCarSchedule" ClientInstanceName="splitterServiceCarSchedule" runat="server" Height="600px" Width="100%">
        <Styles>
            <Pane>
                <Paddings Padding="0px" />
            </Pane>
        </Styles> 
        <Panes>
            <dx:SplitterPane Name="spFilterOptions" ShowCollapseForwardButton="True" MinSize="250px" MaxSize="250px">
                <ContentCollection>
                    <dx:SplitterContentControl runat="server" Width="250px">
                        <dxe:ASPxComboBox ID="ddlContainer" ClientInstanceName="ddlContainer" runat="server" Width="248px">
                            <ClientSideEvents SelectedIndexChanged="function(s, e) { gvServiceCarSchedulePacking.PerformCallback()  }" />
                        </dxe:ASPxComboBox>
                        <dxe:ASPxCalendar ID="calScheduleDate" ClientInstanceName="calScheduleDate" runat="server" Width="248px" OnDayRender="calScheduleDate_DayRender">
                            <ClientSideEvents SelectionChanged="function(s, e) { gvServiceCarSchedulePacking.PerformCallback()  }" />
                        </dxe:ASPxCalendar>
                    </dx:SplitterContentControl>
                </ContentCollection>
            </dx:SplitterPane>
            <dx:SplitterPane Name="spPackingList">
                <ContentCollection>
                    <dx:SplitterContentControl ID="SplitterContentControl3" runat="server">
                        <dxwgv:ASPxGridView ID="gvServiceCarSchedulePacking" runat="server" ClientInstanceName="gvServiceCarSchedulePacking" 
                            KeyFieldName="ServiceCarScheduleDetailId" Width="100%" AutoGenerateColumns="False" EnableCallBacks="True" 
                            oncustomunboundcolumndata="gvServiceCarSchedulePacking_CustomUnboundColumnData" 
                            oncustombuttoncallback="gvServiceCarSchedulePacking_CustomButtonCallback" 
                            OnCustomCallback="gvServiceCarSchedulePacking_CustomCallback">
                            <SettingsLoadingPanel Text="Henter&amp;hellip;" />
                            <Border BorderWidth="0px" />
                            <Settings ShowHeaderFilterButton="False" ShowGroupPanel="false" ShowFilterRow="False" />
                            <SettingsPager AlwaysShowPager="False" PageSize="20" Position="TopAndBottom">
                                <Summary 
                                    AllPagesText="Sider: {0} - {1} ({2} hjulsæt til pakning)" 
                                    Text="Side {0} af {1} ({2} hjulsæt til pakning)" />
                            </SettingsPager>
                            <SettingsBehavior AllowFocusedRow="false" ConfirmDelete="True" AllowGroup="true" AllowDragDrop="false" />
                            <Columns>
                                <dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0">
                                        <HeaderTemplate>
                                            <input type="checkbox" onclick="gvServiceCarSchedulePacking.SelectAllRowsOnPage(this.checked);" style="vertical-align:middle;" title="Vælg/Fravælg alle linjer på siden"></input>
                                        </HeaderTemplate>
                                        <HeaderStyle Paddings-PaddingTop="1" Paddings-PaddingBottom="1" 
                                            HorizontalAlign="Center">
                                        <Paddings PaddingTop="1px" PaddingBottom="1px"></Paddings>
                                        </HeaderStyle>
                                </dxwgv:GridViewCommandColumn>
                                <%--<dxwgv:GridViewCommandColumn VisibleIndex="1">
                                    <CustomButtons>
                                        <dxwgv:GridViewCommandColumnCustomButton Text="Indsæt før" ID="CarNeedServiceInsertBefore" />
                                        <dxwgv:GridViewCommandColumnCustomButton Text="Indsæt efter" ID="CarNeedServiceInsertAfter" />
                                    </CustomButtons>
                                </dxwgv:GridViewCommandColumn>--%>
                                <dxwgv:GridViewDataHyperLinkColumn FieldName="ContainerCargoRoomId" VisibleIndex="3" Caption="Labels">
                                    <PropertiesHyperLinkEdit NavigateUrlFormatString="~/Reports/View/TireSetLabels.aspx?ContainerCargoRoomId={0}" Target="_blank" Text="Vis labels" >
                                    </PropertiesHyperLinkEdit>
                                </dxwgv:GridViewDataHyperLinkColumn>
                                <dxwgv:GridViewDataColumn FieldName="CarId" Visible="false" VisibleIndex="4" Caption="CarId">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="CustomerId" Visible="false" VisibleIndex="4" Caption="CustomerId">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="TireSetId" Visible="false" VisibleIndex="4" Caption="TireSetId">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="SubscriptionId" Visible="false" VisibleIndex="4" Caption="SubscriptionId">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="ContainerId" Visible="false" VisibleIndex="4" Caption="ContainerId">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="Height" Visible="false" VisibleIndex="4" Caption="Height">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="Width" Visible="false" VisibleIndex="4" Caption="Width">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="Size" Visible="false" VisibleIndex="4" Caption="Size">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataTextColumn FieldName="ServiceCarDescription" VisibleIndex="4" Caption="Servicebil">
                                </dxwgv:GridViewDataTextColumn>
                                <dxwgv:GridViewDataColumn FieldName="SequenceNumber" VisibleIndex="6" Caption="Sekvensnr">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataTextColumn FieldName="CargoRoomNumber" VisibleIndex="5" Caption="Lagerplads">
                                </dxwgv:GridViewDataTextColumn>
                                <%--<dxwgv:GridViewDataTextColumn FieldName="CarBrandDescription" VisibleIndex="6" Caption="Bilmærke">
                                </dxwgv:GridViewDataTextColumn>--%>
                                <dxwgv:GridViewDataColumn FieldName="Model" VisibleIndex="7" Caption="Model">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="RegistrationNumber" VisibleIndex="8" Caption="Reg.nr.">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="TireTypeDescription" VisibleIndex="9" Caption="Type">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="TireBrandDescription" VisibleIndex="10" Caption="Dækmærke">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="TireDimensions" UnboundType="String" VisibleIndex="11" Caption="Dimensioner">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="DummyTireSet" VisibleIndex="12" ToolTip="Angiver om dette er et dummy hjulsæt pga. vi endnu ikke har været ude ved kunden og fået hjul med hjem" Caption="Dummy">
                                </dxwgv:GridViewDataColumn>
                                <dxwgv:GridViewDataColumn FieldName="NeedBalancing" VisibleIndex="13" ToolTip="Angiver om hjulene skal afbalanceres" Caption="Skal afbalanceres">
                                </dxwgv:GridViewDataColumn>
                            </Columns>                                            
                        </dxwgv:ASPxGridView>            
                                                    

                    </dx:SplitterContentControl>
                </ContentCollection>
            </dx:SplitterPane>
        </Panes>
    </dx:ASPxSplitter>
                
    <dxwgv:ASPxGridViewExporter ID="gvExport" runat="server" GridViewID="gvServiceCarSchedulePacking">
    </dxwgv:ASPxGridViewExporter>
                
            
    
</asp:Content>
